<?php
/**
*	接口文件
*	createname：雨中磐石
*	homeurl：http://www.rockoa.com/
*	Copyright (c) 2016 rainrock (www.rockoa.com)
*	Date:2016-01-01
*	explain：返回200为正常
*/

class apiAction extends ActionNot
{
	public $logincheck = true;
	
	
	public function initAction()
	{
		$this->display	= false;
		if($this->logincheck){
			$uid 	= $this->adminid;
			if($token = $this->get('token')){$lrs = m('login')->getone("`token`='$token'");$uid=0;if($lrs)$uid = $lrs['aid'];}
			if($uid==0)$this->showreturn('','登录已失效，请重新登录', 199);
			$this->getAdmininfo($uid);
		}
	}
	
	public function getvals($nae, $dev='')
	{
		$sv = $this->rock->jm->base64decode($this->post($nae));
		if($this->isempt($sv))$sv=$dev;
		return $sv;
	}
	
	public function getpostdata()
	{
		$postdata = '';
		if(isset($GLOBALS['HTTP_RAW_POST_DATA']))$postdata = $GLOBALS['HTTP_RAW_POST_DATA'];
		if($postdata=='')$postdata = trim(file_get_contents('php://input'));
		return $postdata;
	}
	
	/**
	*	获取cli上参数格式：-key=val
	*/
	public function getparams($key, $dev='')
	{
		if(PHP_SAPI != 'cli'){
			return $this->get($key, $dev);
		}
		return getparams($key, $dev);
	}
}